package com.tbit.uqbike.service.business.impl;

import com.tbit.uqbike.object.pojo.HotIntelligentSite;
import com.tbit.uqbike.service.business.HotIntelligentSiteService;
import com.tbit.uqbike.webmanager.dao.core.HotIntelligentSiteDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：hzw
 * @date ：Created in 2021/8/27 16:08
 * @description：热点站点推荐业务层
 * @modified By：
 * @version: $
 */
@Service(value = "hotIntelligentSiteService")
public class HotIntelligentSiteServiceImpl implements HotIntelligentSiteService {
    @Autowired
    private HotIntelligentSiteDao hotIntelligentSiteDao;

    @Override
    public List<HotIntelligentSite> queryPage(Long startTime, Long endTime, Integer state, Integer pageNO, Integer rowCount, Integer accountId) {
        Map<String, Object> map = new HashMap<>();
        if (null != startTime && null != endTime) {
            map.put("startTime", new Date(startTime));
            map.put("endTime", new Date(endTime));
        }
        map.put("state", state);
        map.put("pageNO", (pageNO - 1) * rowCount);
        map.put("rowCount", rowCount);
        map.put("accountId", accountId);
        return hotIntelligentSiteDao.queryPage(map);
    }

    @Override
    public Integer queryCount(Long startTime, Long endTime, Integer state, Integer accountId) {
        Map<String, Object> map = new HashMap<>();
        if (null != startTime && null != endTime) {
            map.put("startTime", new Date(startTime));
            map.put("endTime", new Date(endTime));
        }
        map.put("state", state);
        map.put("accountId", accountId);
        return hotIntelligentSiteDao.queryCount(map);
    }

    @Override
    public void handle(HotIntelligentSite hotIntelligentSite) {
        hotIntelligentSiteDao.handle(hotIntelligentSite);
    }

    @Override
    public HotIntelligentSite getHotIntelligentSite(Integer siteId) {
        return hotIntelligentSiteDao.getDataById(siteId);
    }
}
